home *** CD-ROM | disk | FTP | other *** search
/ The World of Computer Software / The World of Computer Software.iso / dec92.zip / 1012023A < prev    next >
Text File  |  1992-10-13  |  1KB  |  48 lines

  1. /*
  2.  * REAL_ISR.C  Copyright (C) 1992 Mark R. Nelson.
  3.  *
  4.  * This header file contains the source code for the real time
  5.  * interrupt service routine used in the TERM286.H program.
  6.  * It also contains the only copy of the data structure used to
  7.  * access the UART.
  8.  *
  9.  */
  10.  
  11. #include <dos.h>
  12. #include <conio.h>
  13. #include "phapi.h"
  14. #include "term286.h"
  15.  
  16. /*
  17.  * This is the data structure used by both the real and protected
  18.  * mode interrupt service routines.
  19.  */
  20. struct port_data Port;
  21.  
  22. /*
  23.  * This is the real mode ISR.  It is identical to the protected mode
  24.  * ISR, except for the increment of the real mode interrupt count
  25.  * near the end.  This routine reads in the character that caused the
  26.  * interrupt, then tries to stuff it in the buffer and update the
  27.  * head pointer.  Finally, it increments the diagnostic counter,
  28.  * outputs an EOI to the 8259 PIC, and exits.
  29.  */
  30.  
  31. void far interrupt real_isr()
  32. {
  33.     unsigned char c;
  34.     int space_used;
  35.  
  36.     c = ( unsigned char ) inp( Port.uart_address );
  37.     space_used = Port.head_pointer - Port.tail_pointer;
  38.     if ( space_used < 0 )
  39.         space_used += 1024;
  40.     if ( space_used < 1023 ) {
  41.         Port.buffer[ Port.head_pointer++ ] = c;
  42.         Port.head_pointer &= 1023;
  43.     }
  44.     Port.real_count++;
  45.     (void) outp( 0x20, 0x20 );
  46. }
  47.  
  48.